package com.anne.fish.model;

import com.anne.fish.model.BaseObject;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableComponent;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import javax.xml.bind.annotation.XmlRootElement;

import java.io.Serializable;

@Entity
@Table(name="area",catalog="fish")
@Searchable
@XmlRootElement
public class Area extends BaseObject implements Serializable {
    private Long id;
    private Long fatherId;
    private String name;
    private Integer class_;
    private boolean type;
    private String prefix;

    @Id @GeneratedValue(strategy=IDENTITY) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="father_id", nullable=false)
    @SearchableProperty
    public Long getFatherId() {
        return this.fatherId;
    }
    
    public void setFatherId(Long fatherId) {
        this.fatherId = fatherId;
    }
    
    @Column(name="name", nullable=false, length=200)
    @SearchableProperty
    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(name="class", nullable=false)
    @SearchableProperty
    public Integer getClass_() {
        return this.class_;
    }
    
    public void setClass_(Integer class_) {
        this.class_ = class_;
    }
    
    @Column(name="type", nullable=false)
    @SearchableProperty
    public boolean isType() {
        return this.type;
    }
    
    public void setType(boolean type) {
        this.type = type;
    }
    
    @Column(name="prefix", nullable=false, length=10)
    @SearchableProperty
    public String getPrefix() {
        return this.prefix;
    }
    
    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Area pojo = (Area) o;

        if (fatherId != null ? !fatherId.equals(pojo.fatherId) : pojo.fatherId != null) return false;
        if (name != null ? !name.equals(pojo.name) : pojo.name != null) return false;
        if (class_ != null ? !class_.equals(pojo.class_) : pojo.class_ != null) return false;
        if (type != pojo.type) return false;
        if (prefix != null ? !prefix.equals(pojo.prefix) : pojo.prefix != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (fatherId != null ? fatherId.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (class_ != null ? class_.hashCode() : 0);
        result = 31 * result + (type ? 1 : 0);
        result = 31 * result + (prefix != null ? prefix.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("fatherId").append("='").append(getFatherId()).append("', ");
        sb.append("name").append("='").append(getName()).append("', ");
        sb.append("class_").append("='").append(getClass_()).append("', ");
        sb.append("type").append("='").append(isType()).append("', ");
        sb.append("prefix").append("='").append(getPrefix()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
